//
//  UserInfo.swift
//  guard
//
//  Created by linus on 2021/11/21.
//

import UIKit

public class UserInfo: NSObject {
    public class Address: NSObject {
        public var country: String?
        public var postal_code: String?
        public var region: String?
        public var formatted: String?
    }
    
    public var id: String?
    public var sub: String?
    public var birthday: String?
    public var family_name: String?
    public var gender: String?
    public var given_name: String?
    public var locale: String?
    public var middle_name: String?
    public var name: String?
    public var nickname: String?
    public var picture: String?
    public var preferred_username: String?
    public var profile: String?
    public var updated_at: String?
    public var website: String?
    public var zoneinfo: String?
    public var email: String?
    public var email_verified: Bool?
    public var address: Address?
    public var phone_number: String?
    public var phone_number_verified: Bool?
    
    public var accessToken: String?
    public var idToken: String?
    public var thirdPartySource: String?
    
    public static func createUserInfo(data: NSDictionary) -> UserInfo {
        let userInfo = UserInfo()
        userInfo.id = data.object(forKey: "id") as? String
        userInfo.name = data.object(forKey: "username") as? String
        userInfo.phone_number = data.object(forKey: "phone") as? String
        userInfo.email = data.object(forKey: "email") as? String
        userInfo.accessToken = data.object(forKey: "token") as? String
        return userInfo
    }
}
